// 参数配置
<template>
  <div class="big_box" id="userBig">
    <el-tabs class="scorllFixed" v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="item.name" :name="item.path" v-for="item in jurisdiction" :key="item.name">
        <router-view v-if="activeName === item.path"></router-view>
      </el-tab-pane>
      <!-- <el-tab-pane label="本地IoT配置" name="iotParameter">
        <router-view v-if="activeName === 'iotParameter'"></router-view>
      </el-tab-pane>
      <el-tab-pane label="问题剔除配置" name="problemKickOut">
        <router-view v-if="activeName === 'problemKickOut'"></router-view>
      </el-tab-pane>-->
    </el-tabs>
  </div>
  <!-- <div class="xiaoxiao">
    <div class="big_box" id="userBig">
      <el-tabs type="card" v-model="activeName" @tab-click="handleClick" style="margin: 0 15px 0 15px">
        <el-tab-pane :label="item.name" :name="item.path" v-for="item in jurisdiction" :key="item.name">
          <router-view v-if="activeName === item.path"></router-view>
        </el-tab-pane>
      </el-tabs>
    </div>
  </div>-->
</template>
<script>
import { setUrl } from '@/utils/getUrl.js'
import { getAuthority } from '@/assets/js/getAuthority.js'
export default {
  data() {
    return {
      activeName: 'iotParameter',
      jurisdiction: [],
    }
  },
  watch: {
    // 监听url中的hash值的变化
    $route(to, from) {
      const hashUrl = window.location.hash.substr(2)
      if (hashUrl.startsWith('iotParameter')) {
        this.activeName = 'iotParameter'
      } else if (hashUrl.startsWith('problemKickOut')) {
        this.activeName = 'problemKickOut'
      } else if (hashUrl.startsWith('voltageCurrent')) {
        this.activeName = 'voltageCurrent'
      } else if (hashUrl.startsWith('txpz')) {
        this.activeName = 'txpz'
      }
      // else if (hashUrl.startsWith('alarmConfig')) {
      //   this.activeName = 'alarmConfig'
      // }
    },
  },
  created() {
    getAuthority(this, 'parameter') // 获取权限
    // const menus = JSON.parse(getUrl('jurisdiction'))
    // this.activeName = menus[0].qxfwlj
    // let obj = {}
    // menus.forEach((item) => {
    //   obj = {
    //     name: item.qxmc,
    //     path: item.qxfwlj,
    //   }
    //   this.jurisdiction.push(obj)
    // })
    // // 判断本地存储中是否有地址
    // let url = getUrl('parameter')
    // if (!url) {
    //   setUrl('parameter', this.jurisdiction[0].path)
    //   url = this.jurisdiction[0].path
    // }
    // this.activeName = url
  },
  mounted() {
    // startLoading(document.getElementById('userBig'))
  },
  updated() {},
  destroyed() {
    // 默认
    setUrl('parameter', '')
  },
  methods: {
    // 刷新右侧需要调用的函数
    getChildRefresh() {
      getAuthority(this, 'parameter') // 获取权限
    },
    handleClick(tab, event) {
      setUrl('parameter', tab.name)
      if (tab.name === 'iotParameter') {
        this.$router.push('/iotParameter')
      } else if (tab.name === 'problemKickOut') {
        this.$router.push('/problemKickOut')
      } else if (tab.name === 'voltageCurrent') {
        this.$router.push('/voltageCurrent')
      } else if (tab.name === 'txpz') {
        this.$router.push('/txpz')
      }
      // else if (tab.name === 'alarmConfig') {
      //   this.$router.push('/alarmConfig')
      // }
    },
  },
}
</script>

<style lang="scss" scoped>
::v-deep .el-tabs__nav-scroll {
  position: relative !important;
  //   width: 0 !important;
}
.xiaoxiao {
  padding: 15px;
  box-sizing: border-box;
  .big_box {
    padding-top: 15px;
  }
}
</style>
